package com.teacherprofile.manage.controller;

import java.util.List;

import com.teacherprofile.common.core.controller.BaseController;
import com.teacherprofile.common.domain.AcademicPapers;
import com.teacherprofile.common.utils.StringUtils;
import com.teacherprofile.manage.domain.dto.SocialParttimeExportDTO;
import jakarta.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.teacherprofile.common.annotation.Log;
import com.teacherprofile.common.core.controller.BaseController;
import com.teacherprofile.common.core.domain.AjaxResult;
import com.teacherprofile.common.enums.BusinessType;
import com.teacherprofile.common.domain.SocialParttime;
import com.teacherprofile.manage.service.ISocialParttimeService;
import com.teacherprofile.common.utils.poi.ExcelUtil;
import com.teacherprofile.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 社会兼职Controller
 * 
 * @author qvtu
 * @date 2025-05-15
 */
@Api(tags = "社会兼职")
@RestController
@RequestMapping("/manage/social_parttime")
public class SocialParttimeController extends BaseController
{
    @Autowired
    private ISocialParttimeService socialParttimeService;

    /**
     * 查询社会兼职列表
     */
    @ApiOperation(value = "查询社会兼职列表")
    @PreAuthorize("@ss.hasPermi('manage:social_parttime:list')")
    @GetMapping("/list")
    public TableDataInfo list(SocialParttime socialParttime)
    {
        startPage();
        List<SocialParttime> list = socialParttimeService.selectSocialParttimeList(socialParttime);
        return getDataTable(list);
    }

    /**
     * 导出社会兼职列表
     */
    @ApiOperation(value = "导出社会兼职列表")
    @PreAuthorize("@ss.hasPermi('manage:social_parttime:export')")
    @Log(title = "社会兼职", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SocialParttimeExportDTO dto)
    {
        List<SocialParttime> list = socialParttimeService.selectSocialParttimeList(dto);
        ExcelUtil<SocialParttime> util = new ExcelUtil<SocialParttime>(SocialParttime.class);
        util.exportEasyExcel(response, list, "社会兼职数据", StringUtils.str2List(dto.getExportFields(), ",", true, true));
    }

    /**
     * 获取社会兼职详细信息
     */
    @ApiOperation(value = "获取社会兼职详细信息")
    @PreAuthorize("@ss.hasPermi('manage:social_parttime:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(socialParttimeService.selectSocialParttimeById(id));
    }

    /**
     * 新增社会兼职
     */
    @ApiOperation(value = "新增社会兼职")
    @PreAuthorize("@ss.hasPermi('manage:social_parttime:add')")
    @Log(title = "社会兼职", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SocialParttime socialParttime)
    {
        return toAjax(socialParttimeService.insertSocialParttime(socialParttime));
    }

    /**
     * 修改社会兼职
     */
    @ApiOperation(value = "修改社会兼职")
    @PreAuthorize("@ss.hasPermi('manage:social_parttime:edit')")
    @Log(title = "社会兼职", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SocialParttime socialParttime)
    {
        return toAjax(socialParttimeService.updateSocialParttime(socialParttime));
    }

    /**
     * 删除社会兼职
     */
    @ApiOperation("删除社会兼职")
    @PreAuthorize("@ss.hasPermi('manage:social_parttime:remove')")
    @Log(title = "社会兼职", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(socialParttimeService.deleteSocialParttimeByIds(ids));
    }

    /**
     * 导入社会兼职
     * @param file
     * @return
     * @throws Exception
     */
    @ApiOperation("导入社会兼职")
    @Log(title = "导入管理", businessType = BusinessType.IMPORT)
    @PreAuthorize("@ss.hasPermi('system:social_parttime:import')")
    @PostMapping("/importData")
    public AjaxResult importData(MultipartFile file) throws Exception {
        ExcelUtil<SocialParttime> util = new ExcelUtil<SocialParttime>(SocialParttime.class);
        List<SocialParttime> socialParttimes = util.importEasyExcel(file.getInputStream());
        String message = socialParttimeService.importData(socialParttimes);
        return success(message);
    }

    /**
     * 审批
     */
    @ApiOperation(value = "论文审批")
    @PreAuthorize("@ss.hasPermi('manage:social_parttime:check')")
    @Log(title = "社会兼职", businessType = BusinessType.UPDATE)
    @PutMapping("/check")
    public AjaxResult check(@RequestBody SocialParttime socialParttimes) {
        return toAjax(socialParttimeService.check(socialParttimes));
    }
}
